// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: 'timemechine-6gk33n8ja79a3c4a'
})

// 云函数入口函数
const db = cloud.database()
exports.main = async (event, context) => {
  if(event.thing != undefined){
    return db.collection('note_list').where({
      "_openid": event.openid,
      thing:db.RegExp({
        regexp: '.*' + event.thing +'.*',
        options: 'i',
      })
    })
    .get();
  } else {
    return db.collection('note_list').where({
      "_openid": event.openid,
    })
    .get();
  }

}